package com.javacoo.fastdfs.client.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import com.javacoo.fastdfs.client.internal.pool.PoolConfig;

import lombok.Data;
import lombok.ToString;

/**
 * FastDFS配置类
 * @author duanyong@jccfc.com
 * @date 2020/4/30 9:48
 */
@ConfigurationProperties(prefix = FastDFSConfig.PREFIX)
@Data
@ToString
public class FastDFSConfig {
    /** FastDFS是否可用,默认值*/
    public static final String PREFIX = "fastdfs";
    /** FastDFS是否可用,默认值*/
    public static final String ENABLED = "enabled";
	/** 连接超时时间,默认值,单位：毫秒*/
	public static final int DEFAULT_CONNECTION_TIMEOUT = 5 * 1000;
	/** 网络超时时间,默认值,单位：毫秒*/
	public static final int DEFAULT_NETWORK_TIMEOUT = 30 * 1000;
    /** 编码,默认值*/
    public static final String DEFAULT_CHARSET = "UTF-8";
	/** tracker 端口HTTP访问服务的端口号,默认值*/
	public static final int DEFAULT_TRACKER_HTTP_PORT = 80;
    /** tracker 地址 多个以逗号分隔,默认值*/
    public static final String DEFAULT_TRACKER_SERVERS = "";
    /** nginx 地址 多个以逗号分隔,默认值*/
    public static final String DEFAULT_NGINX_SERVERS = "";
    /** FastDFS key,默认值*/
    public static final String DEFAULT_SECRET_KEY = "";
    /** 是否需要防盗链token,默认值*/
    public static final boolean DEFAULT_ANTI_STEAL_TOKEN = true;
    /** 获取连接重试次数,默认值*/
    public static final int DEFAULT_RETRY_COUNT = 10;
    /** FastDFS是否可用*/
    private String enabled = ENABLED;
    /** 连接超时时间 */
    private int connectTimeout = DEFAULT_CONNECTION_TIMEOUT;
    /** 网络超时时间 */
    private int networkTimeout = DEFAULT_NETWORK_TIMEOUT;
    /** 编码 */
    private String charset = DEFAULT_CHARSET;
    /** tracker 端口,HTTP访问服务的端口号 */
    private int trackerHttpPort = DEFAULT_TRACKER_HTTP_PORT;
    /** tracker 地址 多个以逗号分隔*/
    private String trackerServers = DEFAULT_TRACKER_SERVERS;
    /** nginx 地址 多个以逗号分隔*/
    private String nginxAddress = DEFAULT_NGINX_SERVERS;
    /** FastDFS key*/
    private String secretKey = DEFAULT_SECRET_KEY;
    /** 是否需要防盗链token */
    private boolean antiStealToken = DEFAULT_ANTI_STEAL_TOKEN;
    /** 获取连接重试次数 */
    private int retryCount = DEFAULT_RETRY_COUNT;
    /** FastDFS连接池配置*/
    @NestedConfigurationProperty
    private PoolConfig poolConfig = new PoolConfig();
}
